linux 网络不通网卡缺陷排查记录

三月 20, 2026 #network

现象

查看ip route ip link ip -4 addr bridge show 等多个命令,没有发现明显问题 怀疑是linux网桥导致的问题,后面发现是物理网卡hung了

查看dmesg

sudo dmesg -w

[318451.739250] e1000e 0000:00:1f.6 enp0s31f6: Detected Hardware Unit Hang:
                  TDH                  <ed>
                  TDT                  <10>
                  next_to_use          <10>
                  next_to_clean        <ec>
                buffer_info[next_to_clean]:
                  time_stamp           <110b9fd62>
                  next_to_watch        <ed>
                  jiffies              <112f6a400>
                  next_to_watch.status <0>
                MAC Status             <40080083>
                PHY Status             <796d>
                PHY 1000BASE-T Status  <3800>
                PHY Extended Status    <3000>
                PCI Status             <10>

诊断结果 核心诊断

解决方案

临时测试(无需重启): 运行以下命令关闭该网卡的 ASPM(主动状态电源管理):

# 注意:需要 root 权限
sudo setpci -s 00:1f.6 0x50.B=0x00
# 如果命令提示找不到 setpci,请先安装:
sudo apt install pciutils
执行完上述命令后,重置网卡:
``` bash
sudo ip link set enp0s31f6 down
sudo ip link set enp0s31f6 up

永久生效(修改 GRUB):

sudo update-grub
sudo reboot

禁用特定的网卡节能功能

如果方案一无效,尝试通过 ethtool 禁用网卡内部的节能选项。

sudo apt install ethtool
sudo ethtool enp0s31f6 | grep -E "Wake-on|Energy"
# 关闭 Wake-on-LAN
sudo ethtool -s enp0s31f6 wol d

# 关闭 Energy Efficient Ethernet (EEE) - 这对 I219 很重要
sudo ethtool --set-eee enp0s31f6 eee off
# 注:如果 --set-eee 提示不支持,可以忽略该行。
# 为了让这些设置在重启后依然有效,你可以创建一个 systemd 服务或将其放入 /etc/network/interfaces (如果是旧版 networking) 或 Netplan 的配置中。

快速临时测试脚本:

sudo ip link set enp0s31f6 down
sudo ethtool -s enp0s31f6 wol d
sudo ethtool --set-eee enp0s31f6 eee off 2>/dev/null
sudo ip link set enp0s31f6 up